/*
 * Copyright (C) 2012 Le Tuan Anh <anh.takaji@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ezcms.dal.hibernate.mysql;

import ezcms.dal.ScaleDAO;
import ezcms.dto.Scale;
import ezcms.exceptions.DataLayerException;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author Le Tuan Anh <anh.takaji@gmail.com>
 */
class ScaleDAOImpl implements ScaleDAO {

    public ScaleDAOImpl() {
    }

    @Override
    public List<Scale> getAllScales() throws DataLayerException {
        return HibernateUtil.getListByConditions(Scale.class, null, "Cannot retrieve all Scales");
    }

    @Override
    public Scale getScaleById(long id) throws DataLayerException {
        Object result = HibernateUtil.getObjectById(Scale.class, id, "Cannot find Scale object with id = " + id);
        return (result == null) ? null : (Scale) result;
    }

    @Override
    public void saveScale(Scale scale) throws DataLayerException {
        HibernateUtil.saveObject(scale, "Cannot save Scale");
    }

    @Override
    public void deleteScale(Scale scale) throws DataLayerException {
        HibernateUtil.deleteObject(scale, "Cannot delete Scale");
    }
}
